package lab05;

import java.util.Scanner;
import java.util.InputMismatchException;

public class task4 {

	public static void main(String[] args) {
		
		int choice;
		double w , d , l , ar ,p;
		double c , r , ac;
		
		
		Scanner sk = new Scanner(System.in);
		
		
		System.out.println("1.  Find area and perimeter of a rectangle");
		System.out.println("2.  Find area and circumference of a circle");
		
		try {
			System.out.print("Enter your choice:");
			
			choice = sk.nextInt();
			
			if(choice == 1)
			{
				System.out.print("Enter the wigth:");
				w = sk.nextDouble();
				System.out.print("Enter the diagonal:");
				d = sk.nextDouble();
				
				l = Math.sqrt(Math.pow(d,2)-Math.pow(w,2));
				
				ar = w * l;
				p = 2 * (w+l);
				
				System.out.printf("area = %.2f square cm , perimeter = %.2f cm",ar , p);
			}
			else if(choice == 2)
			{
				System.out.print("Enter the circumference:");
				c = sk.nextDouble();
				r = c / (2 * Math.PI);
				ac = Math.PI * Math.pow(r, 2);
				
				System.out.printf("area = %.2f square cm",ac);
			}
			else
				System.out.println("Error: Wrong menu choice");
		}catch(InputMismatchException e){
			System.out.println("Error: Input Mismatch Exception");
		}
		
		
		
		
		
		
		
		
		

	}

}
